import request from "@/util/request"

export function getGoodList(currentPage, pageNum, searchContent) {
    return request({
        url: "/goods/getGoodList",
        method: "get",
        params: {
            currentPage: currentPage,
            pageNum: pageNum,
            keyword: searchContent
        }
    })
}

export function delGood(goods_id) {
    return request({
        url: "/goods/delGood",
        method: "delete",
        data: {
            goods_id: goods_id
        }
    })
}

export function getTotalLevel0Num() {
    return request({
        url: "/goods/getTotalLevel0Num",
        method: "get",
    })
}

export function getGoodCategory(currentPage, pageNum) {
    return request({
        url: "/goods/getGoodCategory",
        method: "get",
        params: {
            currentPage,
            pageNum
        }
    })
}

export function getGoodCateTwoLevel() {
    return request({
        url: "/goods/getGoodCateTwoLevel",
        method: "get",
    })
}

export function getGoodAttribute(cat_id) {
    return request({
        url: "/goods/getGoodAttribute",
        method: "get",
        params: {
            cat_id: cat_id
        }
    })
}

export function addGood(goodForm) {
    return request({
        url: "/goods/addGood",
        method: "post",
        data: goodForm
    })
}

export function editCategoryName(cat_id, cat_name) {
    return request({
        url: "/goods/editCategoryName",
        method: "post",
        data: {
            cat_id,
            cat_name
        }
    })
}

export function delGoodCategory(cat_id) {
    return request({
        url: "/goods/delGoodCategory",
        method: "post",
        data: {
            cat_id
        }
    })
}

export function addGoodCategory(cat_pid, cat_name, cat_level) {
    return request({
        url: "goods/addGoodCategory",
        method: "post",
        data: {
            cat_pid,
            cat_name,
            cat_level
        }
    })
}

export function getCateAttribute(cat_id) {
    return request({
        url: "/cateParams/getCateAttribute",
        method: "get",
        params: {
            cat_id,
        }
    })
}

export function delCateAttribute(attr_id) {
    return request({
        url: "/cateParams/delCateAttribute",
        method: "delete",
        params: {
            attr_id
        }
    })
}

export function editCateAttribute(attr_id, attr_name, attr_vals) {
    return request({
        url: "/cateParams/editCateAttribute",
        method: "post",
        data: {
            attr_id,
            attr_name,
            attr_vals
        }
    })
}

export function addCateAttribute(cat_id, attr_name, attr_sel, attr_vals) {
    return request({
        url: "/cateParams/addCateAttribute",
        method: "post",
        data: {
            cat_id,
            attr_name,
            attr_sel,
            attr_vals
        }
    })
}